<%@ page pageEncoding="UTF-8"%>
<%@ include file="../commons/head.jsp"%>
<style>
.datagrid-body {
	height: 290px !important;
}

.datagrid-view {
	height: 350px !important;
}
.datagrid-ftable{
	color:red;
}
</style>
<script type="text/javascript">
	var data;
	var flag = 0;
	var del = 0;
	$(function() {
		$('#tt')
				.datagrid(
						{
							rowStyler : function(index, row) {
								if (row.name != row.nameForCard) {
									if (index % 2 == 0) {
										return 'background-color:lightcyan;color:red;font-weight:bold;';
									} else {
										return 'color:red;font-weight:bold;';
									}
								} else {
									if (index % 2 == 0) {
										return 'background-color:lightcyan;';
									}
								}
							}
						});
		$.ajaxSetup({
			cache : false
		//关闭AJAX相应的缓存
		});

		//点击查询
		$("#search").click(function() {debugger
			var params = {
				cellphone : $("#cellphone").val(),
				createTimeFrom : $("#createTimeFrom").datebox('getValue'),
				createTimeTo : $("#createTimeTo").datebox('getValue'),
				withdrawCashFrom : $("#withdrawCashFrom").val(),
				withdrawCashTo : $("#withdrawCashTo").val(),
			};
			$("#tt").datagrid('load', params);
			//datagrid取消选中方法： 
			$("#tt").datagrid("unselectAll");
		});

		//导出
		$("#export")
				.click(
						function() {
							var params = {
								cellphone : $("#cellphone").val(),
								createTimeFrom : $("#createTimeFrom").datebox(
										'getValue'),
								createTimeTo : $("#createTimeTo").datebox(
										'getValue'),
								withdrawCashFrom : $("#withdrawCashFrom").val(),
								withdrawCashTo : $("#withdrawCashTo").val(),
							};
							window.location.href = "${pageContext.request.contextPath}/audit/export?cellphone="
									+ params.cellphone
									+ "&createTimeFrom="
									+ encodeURI(params.createTimeFrom)
									+ "&createTimeTo="
									+ encodeURI(params.createTimeTo)
									+ "&withdrawCashFrom="
									+ encodeURI(params.withdrawCashFrom)
									+ "&withdrawCashTo="
									+ encodeURI(params.withdrawCashTo);
						});

	});

	function reload() {
		$("#tt").datagrid('reload');
		//datagrid取消选中方法： 
		$("#tt").datagrid("unselectAll");
	};

	//行按钮
	function formatOper(val, row, index) {
		if (row.id != null) {
			return '<a class="easyui-linkbutton l-btn" style="width:70px" href="javascript:checkOne(\''
					+ row.orderNumber
					+ '\');"><span class="l-btn-left"><span class="l-btn-text">审核</span></span></a>';
		} else {
			return '';
		}
	}
	function checkOne(orderNumber) {
		$("#orderNumber").val(orderNumber);
		//$("#closepagesave").dialog("open");
		$("#dlg").dialog("open");
		$(".panel-title").text('审核');
	}
	function checkAll() {
		var rows = $('#tt').datagrid('getSelections');//所有选中的数据
		var orderNumber;
		if (rows.length == 0) {
			$.messager.alert("温馨提示：", "请至少选择一行", "error");
			return;
		} else {
			for (var i = 0; i < rows.length; i++) {
				if (i == 0) {
					orderNumber = rows[i].orderNumber;
				} else {
					orderNumber += "," + rows[i].orderNumber;
				}
			}
			$("#orderNumber").val(orderNumber);
			//$("#closepagesave").dialog("open");
			$("#dlg").dialog("open");
			$(".panel-title").text('审核');
		}
	}
	function saved(flg) {
		var orderNumber = $("#orderNumber").val();
		$.ajax({
			url : "${pageContext.request.contextPath}/audit/auditSuccess",
			type : "POST",
			data : {
				'orderNumber' : orderNumber,
				'flg' : flg
			},
			cache : false,
			success : function(data) {
				$("#dlg").dialog("close");
				$.messager.alert("成功", "审核成功！", "info", reload);
			}
		});
	}
	

	function rowStyle(index, row) {
		if (index % 2 == 0) {
			return 'background-color:lightcyan;';
		}
	}
	//日期格式化
	function gettime(val, row, index) {
		var m = "";
		if (val != null) {
			var s = val.substr(0, 10);
			var ss = val.substr(11, 8);
			var m = s;
		}
		return m;
	}

	//金额格式化
	function formatMoney(number) {
		
		number = Math.round(number * 100) / 100;
		return outputDollars(Math.floor(number - 0) + '')
				+ outputCents(number - 0);
	}
	function outputDollars(number) {
		if (number.length <= 3)
			return (number == '' ? '0' : number);
		else {
			var mod = number.length % 3;
			var output = (mod == 0 ? '' : (number.substring(0, mod)));
			for (i = 0; i < Math.floor(number.length / 3); i++) {
				if ((mod == 0) && (i == 0))
					output += number.substring(mod + 3 * i, mod + 3 * i + 3);
				else
					output += ','
							+ number.substring(mod + 3 * i, mod + 3 * i + 3);
			}
			return (output);
		}
	}
	function outputCents(amount) {
		amount = Math.round(((amount) - Math.floor(amount)) * 100);

		if (amount == 10 || amount == 20 || amount == 30 || amount == 40
				|| amount == 50 || amount == 60 || amount == 70 || amount == 80
				|| amount == 90) {
			amount = (amount.toString()).substr(0,
					(amount.toString()).length - 1);
			return '.' + amount;
		} else if (amount == 0) {
			return "";
		} else if (amount == 1 || amount == 2 || amount == 3 || amount == 4
				|| amount == 5 || amount == 6 || amount == 7 || amount == 8
				|| amount == 9) {
			return '.0' + amount;
		} else {
			return '.' + amount;
		}
	}
	//鼠标悬停显示提示
	function showTips(value, row, index) {
		var content = '';
		if (value != null && value != '') {
			if (value.length > 6 && strDateTime(value)) { //如果为时间
				value = value.substr(0, 10);
			}
			content = '<span title="' + value + '" class="note" >' + value
					+ '</span>';
		}
		return content;
	}
	function showMoneyTips(value, row, index) {
		var m = formatMoney(value, row, index);
		return showTips(m);
	}
	//判断是否为时间格式 yyyy-MM-dd HH:mm:ss
	function strDateTime(str) {
		var reg = /^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})$/;
		var r = str.match(reg);
		if (r == null)
			return false;
		var d = new Date(r[1], r[3] - 1, r[4], r[5], r[6], r[7]);
		return (d.getFullYear() == r[1] && (d.getMonth() + 1) == r[3]
				&& d.getDate() == r[4] && d.getHours() == r[5]
				&& d.getMinutes() == r[6] && d.getSeconds() == r[7]);
	}
</script>
<body>
	<div class="jianju">
		<h3>待审核</h3>
		<div class="panel datagrid easyui-fluid" style="width: 1135px;">
			<div class="datagrid-wrap panel-body panel-body-noheader" title=""
				style="width: 1135px;">
				<div id="tb" style="padding: 0px; height: auto"
					class="datagrid-toolbar">
					<div style="margin-bottom: 5px">
						<a id="AuditBat" href="javascript:checkAll()"
							class="easyui-linkbutton button l-btn l-btn-small"
							iconcls="l-btn-icon icon-shenhe" group="">批量审核<span
							class="l-btn-icon icon-shenhe">&nbsp;</span></a> <a id="export"
							href="#" class="easyui-linkbutton button l-btn l-btn-small"
							iconcls="icon-daochu" group="">导出<span
							class="l-btn-icon icon-daochu">&nbsp;</span></a>
					</div>
					<hr>
					<div>
						<label>会员手机号：</label><input id="cellphone"
							class="easyui-numberbox numberbox-f textbox-f"
							style="width: 100px; display: none;"> <label
							style="margin-left: 15px;">申请时间：</label><input
							id="createTimeFrom" type="text"
							class="easyui-datebox datebox-f combo-f textbox-f"
							editable="false" style="width: 110px; display: none;">~ <input
							id="createTimeTo" type="text"
							style="width: 110px; display: none;" editable="false"
							class="easyui-datebox datebox-f combo-f textbox-f"> <label
							style="margin-left: 15px;">申请金额：</label><input
							id="withdrawCashFrom" type="text"
							class="easyui-numberbox numberbox-f textbox-f"
							style="width: 100px; display: none;"> ~ <input
							id="withdrawCashTo" type="text"
							style="width: 100px; display: none;"
							class="easyui-numberbox numberbox-f textbox-f"> <a
							id="search" href="#"
							class="easyui-linkbutton button l-btn l-btn-small"
							style="margin-left: 15px;" iconcls="icon-search" group="">查询<span
							class="l-btn-icon icon-search">&nbsp;</span></a>
					</div>
				</div>
			
				<table id="tt" class="easyui-datagrid datagrid-f"
					url="${pageContext.request.contextPath}/audit/list" title=""
					style="display: none;" iconcls="icon-save" rownumbers="true"
					pagination="true" pagelist="[10,20,30,40]" method="get"
					toolbar="#tb" singleselect="false" checkonselect="true"
					selectoncheck="true" fitcolumns="true" idfield="id"
					showfooter="true" rowstyler="rowStyle"
					onloadsuccess:function(data){="" $(".note").tooltip({="" onshow:=""
					function(){="" $(this).tooltip('tip').css({="" width:'300',=""
					boxshadow:="" '1px="" 1px="" 3px=""#292929'="" });="" }="">
					<thead>
						<tr style="background: #148CCA;">
							<th data-options="field:'ck',checkbox:true" style="width: 1%"></th>
							<th data-options="field:'id',hidden:true" style="width: 1%">id</th>
							<th
								data-options="field:'orderNumber',align:'left',formatter:showTips"
								style="width: 11%">订单编号</th>
							<th data-options="field:'phone',align:'left',formatter:showTips"
								style="width: 8%">会员手机号</th>
							<th data-options="field:'name',align:'left',formatter:showTips"
								style="width: 8%">会员姓名</th>
							<th
								data-options="field:'applyTime',align:'center',formatter:showTips"
								style="width: 10%">申请时间</th>
							<th data-options="field:'bankforCard',formatter:showTips"
								style="width: 8%">银行</th>
							<th
								data-options="field:'cardNumber',align:'center',formatter:showTips"
								style="width: 14%">卡号</th>
							<th data-options="field:'nameForCard',formatter:showTips"
								style="width: 8%">持卡人姓名</th>
							<th
								data-options="field:'cellphoneForCard',align:'center',formatter:showTips"
								style="width: 10%">预留手机号</th>
							<th
								data-options="field:'money',align:'right',formatter:formatMoney,formatter:showMoneyTips"
								style="width: 8%">申请金额</th>
							<th
								data-options="field:'_operate',align:'center',formatter:formatOper"
								style="width: 12%">操作</th>
						</tr>
					</thead>
				</table>
		</div>
		</div>
	</div>
	
	<div id="dlg" class="easyui-dialog" style="width:200px;height:100px;padding:10px 20px"
		closed="true" buttons="#dlg-buttons" modal="true">
		<div class="ftitle"></div>
		<input id="orderNumber" name="orderNumber" type="hidden" value="">
	</div>
	<div id="dlg-buttons">
		<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="javascript:saved(1)">通过</a>
		<a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:saved(2);">拒绝</a>
	</div>
</body>